package tw.cuttle.core.spring;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

import tw.cuttle.CuttleContext;
import tw.cuttle.bean.Actions;
import tw.cuttle.core.CuttleConfigurationParser;

public class CuttleActionBeanDefinitionParser implements BeanDefinitionParser {
    private Log LOGGER=LogFactory.getLog(CuttleActionBeanDefinitionParser.class);

    public BeanDefinition parse(Element element, ParserContext ctx) {
	Actions actions=CuttleConfigurationParser.getActions(element);
	RootBeanDefinition beanDef = new RootBeanDefinition();
        beanDef.setBeanClass(Actions.class);
        
        CuttleContext.getBeanHolder().setActions(actions);

        return beanDef;
    }

}
